﻿@model CRF
@{
    ViewBag.Title = "病历报告表详情编辑";
    Layout = "~/Views/Shared/Master.cshtml";
}
@{Html.Telerik().Window().Name("CRFEditWindow").Title("病历报告表详情编辑").HtmlAttributes(new { @class = "ContentWindow" })
    .Buttons(buttons => buttons.Clear())
    .Content(
@<text>
    @{using (Ajax.BeginForm<CRFController>(c => c.CRFEdit(null),
        new AjaxOptions { OnBegin = "BeforeSend", OnSuccess = "OnSuccess", OnFailure = "OnError" }))
        {
        <table>
            <tr>
                <th>医院编号</th>
                <td>
                    @Html.HiddenFor(model => model.ID)
                    @Html.DisplayFor(model => model.HospitalCode)
                    @Html.HiddenFor(model=>model.HospitalCode)
                </td>
            </tr>
            <tr>
                <th>病例序号</th>
                <td>
                    @Html.DisplayFor(model => model.CrfCode)
                    @Html.HiddenFor(model=>model.CrfCode)
                </td>
            </tr>
            <tr>
                <th>研究单位</th>
                <td>
                    @Html.DisplayFor(model => model.Hospital.Name)
                    @Html.HiddenFor(model => model.HospitalID)
                </td>
            </tr>
            <tr>
                <th>研究者</th>
                <td>
                    @Html.DisplayFor(model => model.Researcher.RealName)
                    @Html.HiddenFor(model => model.ResearcherID)
                </td>
            </tr>
            <tr>
                <th>开始时间</th>
                <td>@Html.DateEditorFor(model => model.StartTime)</td>
            </tr>
            <tr>
                <th>患者身份证号</th>
                <td>
                    @Html.HiddenFor(model => model.PatientID)
                    @Html.DisplayFor(model => model.Patient.IDCard)
                </td>
            </tr>
            <tr>
                <th>社保号</th>
                <td>
                    @Html.HiddenFor(model => model.PatientID)
                    @Html.DisplayFor(model => model.Patient.SocialID)
                </td>
            </tr>
            <tr>
                <th>患者</th>
                <td>@Html.TextBoxFor(model => model.Patient.Name)</td>
            </tr>
            <tr>
                <th>性别</th>
                <td>@Html.GenderEditorFor(model => model.Patient.Gender)</td>
            </tr>
            <tr>
                <th>民族</th>
                <td>@Html.TextBoxFor(model => model.Patient.Nationality)</td>
            </tr>
            <tr>
                <th>就诊科室</th>
                <td>@Html.TextBoxFor(model => model.Patient.TreatDepart)</td>
            </tr>
            <tr>
                <th>生日</th>
                <td>@Html.DateEditorFor(model => model.Patient.Birthday)</td>
            </tr>
            <tr>
                <th>单位</th>
                <td>@Html.TextBoxFor(model => model.Patient.Company)</td>
            </tr>
            <tr>
                <th>工种</th>
                <td>@Html.TextBoxFor(model => model.Patient.JobKind)</td>
            </tr>
            <tr>
                <th>电话</th>
                <td>@Html.TextBoxFor(model => model.Patient.Phone)</td>
            </tr>
            <tr>
                <th>职业</th>
                <td>@Html.TextBoxFor(model => model.Patient.Job)</td>
            </tr>
            <tr>
                <th>地址</th>
                <td>@Html.TextBoxFor(model => model.Patient.Address)</td>
            </tr>
            <tr>
                <th>出生地</th>
                <td>@Html.TextBoxFor(model => model.Patient.BirthPlace)</td>
            </tr>
            <tr>
                <th>婚姻状况</th>
                <td>@Html.MarriageEditorFor(model => model.Patient.Marriage)</td>
            </tr>
        </table>
        <input type="submit" value="提交" />
        }
    }
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("adding").Title("系统提示")
    .Buttons(buttons => buttons.Clear())
    .ClientEvents(window => window.OnOpen("OnAddingOpen"))
    .Content(
@<text>
正在添加，请稍后...
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("addError").Title("系统提示")
    .Buttons(buttons => buttons.Close())
    .ClientEvents(window => window.OnOpen("OnAddErrorOpen"))
    .Content(
@<text>
出现错误，请重试！
</text>)
    .Render();
}

<script type="text/javascript">
    function OnAddingOpen() {
        $("#adding").data("tWindow").center();
    }
    function OnAddErrorOpen() {
        $("#addError").data("tWindow").center();
    }
    function BeforeSend() {
        $("#adding").data("tWindow").open();
    }
    function OnSuccess(data) {
        if (data.ID) {
            var url = "@(Url.Action<CRFController>(c => c.CRFDetail(Guid.Empty)))";
            url = url.replace("@Guid.Empty", data.ID);
            window.location = url;
        } else {
            $("#addError").data("tWindow").open();
            $("#adding").data("tWindow").close();
        }
    }
    function OnError() {
        $("#addError").data("tWindow").open();
        $("#adding").data("tWindow").close();
    }

</script>